import app_network
import _thread
import time
from machine import Pin


# RTU一共4个可控指示灯
led_4G = Pin(38, Pin.OUT)  # GPIO38 4G LED
led_wifi = Pin(39, Pin.OUT) # GPIO39 wifi LED
led_eth = Pin(40, Pin.OUT) # GPIO40 以太网 LED
led_sta = Pin(21, Pin.OUT) # GPIO21 运行 LED
led_4G.value(0)
led_wifi.value(0)
led_eth.value(0)
led_sta.value(0)

n = 0
def net_led_disp(id):
    global n
    while True:
        net1_connect_flag=app_network.get4gFlag()
        n+=1
        led_sta.value(n%2)
        if net1_connect_flag:
            led_4G.value(n%2)
            led_eth.value(n%2)
            led_wifi.value(n%2)
        time.sleep_ms(500)
        if n>99:
            n=0

  
#开启状态灯线程
def led_disp_thread():
    _thread.start_new_thread(net_led_disp,(2,))


